#pragma once
#include "XVirtualD3D11Drawer.h"
#include <xnamath.h>

#pragma comment (lib, "XD3D11Shapes.lib")

class XCxcD3D11Drawer :
	public XVirtualD3D11Drawer
{
public:
	XCxcD3D11Drawer();
	virtual ~XCxcD3D11Drawer();

	struct Vertex
	{

		void set(float x, float y, float z, float r, float g, float b, float a)
		{
			position = XMFLOAT3(x, y, z);
			color = XMFLOAT4(r, g, b, a);
		}
		
		XMFLOAT3 position;
		XMFLOAT4 color;
	};

	void initializeScene();
	virtual void update();
	virtual void draw();
	void rotateY(float ang);
	void rotateX(float ang);
	void rotateZ(float ang);

protected:
	struct ConstantBuffer
	{
		XMMATRIX World;
		XMMATRIX View;
		XMMATRIX Projection;
	};

	void drawAnchors();
	void drawBall();

	XMMATRIX world;
	XMMATRIX view;
	XMMATRIX projection;

	ID3D11InputLayout *vertexLayout;

	ID3D11VertexShader *vertexShader;
	ID3D11PixelShader *pixelShader;
	ID3D10Blob *vertexShaderBuffer;
	ID3D10Blob *pixelShaderBuffer;
	
	ID3D11Buffer *anchorVertexBuffer;

	int cntBallPoints;
	int cntBallIndices;
	ID3D11Buffer *ballVertexBuffer;
	ID3D11Buffer *ballIndexBuffer;

	ID3D11Buffer *triangleVertexBuffer;
	ID3D11Buffer *triangleIndexBuffer;
	ID3D11Buffer *constantBuffer;
};

